<!--
* description: 优惠券选择
* author: dxuem
* createdDate: 2020-02-19
-->
<template>
  <section class="carTypeConfig">
    <el-dialog
      v-dialogDrag
      title="优惠券选择"
      :visible.sync="curPopupsVisible"
      width="1000px"
      center
      @close="sendCode"
      :close-on-click-modal="false"
      :append-to-body="true"
    >
      <dialogHeader slot="title" :title="'优惠券选择'" :styleType="$store.state.app.dialogType"></dialogHeader>
      <one-table-template
        ref="multipleTable"
        :dynamicButtons="tableButtons"
        :dynamicComponents="tableComponents"
        :dynamicApiConfig="apiConfig"
        :dynamicTableCols="tableCols"
        :dynamicFormFields="formField"
        :dynamicIsShowSelect="isMul"
      />
    </el-dialog>
  </section>
</template>
<script>
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins";
import { valueObjectMixins } from "@/components/mixins/valueObjectMixins";
import { crmApis } from "@/api/apiList/crm";
import OneTableTemplate from "@/components/crm/commonComponents/crmPopupsOneTable";

export default {
  // 组件混入对象：{data[listQuery] methods[queryTable]}
  mixins: [oneTableWithViewTemplateMixins, valueObjectMixins],
  components: {
    OneTableTemplate,
    dialogHeader: () => import("@/components/dialogHeader") //弹窗标题
  },
  data() {
    return {
      // 网格查询API配置对象
      apiConfig: crmApis.mdmOrgdlrQueryByPage, //经销商查询
      // 动态组件-按钮
      tableButtons: [
        {
          compKey: "btnKey1",
          type: "primary",
          size: "small",
          clickEvent: () => this.queryTable(1),
          text: "查询",
          position: "top"
        },
        {
          compKey: "btnKey2",
          type: "primary",
          size: "small",
          clickEvent: () => this.sendCode(this.codeField, "dlrShortName"),
          text: "确认",
          position: "bottom"
        },
        {
          compKey: "btnKey3",
          type: "",
          size: "small",
          clickEvent: () => this.reset(),
          text: "重置",
          position: "top"
        }
      ],
      // 动态组件-查询条件
      tableComponents: [
        // 显示组件
        {
          compKey: "compKey1",
          labelName: "优惠券类型",
          codeField: "dlrShortName",
          component: () => import("@/components/crm/textbox/crmTextInput"),
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey2",
          labelName: "优惠券名称",
          codeField: "carBrandCode",
          textField: "carBrandCn",
          lookuptype: crmApis.mdmCarBrandQueryByPage,
          component: () => import("@/components/crm/lookupValue/apiDropList"),
          type: "dropdownList",
          isMust: true,
          isMul: false
        },
        {
          compKey: "compKey3",
          labelName: "活动类型",
          codeField: "orgType",
          lookuptype: "DB0062",
          component: () => import("@/components/org/LookupValue"),
          type: "dropdownList",
          isMust: true,
          isMul: false
        }
      ],
      // 动态生成网格列
      tableCols: [
        {
          prop: "dlrId",
          label: "优惠券类型",
          width: null,
          hidden: true,
          align: "center"
        },
        {
          prop: "dlrShortName",
          label: "优惠券名称",
          width: 200,
          align: "center"
        },
        {
          prop: "carBrandCn",
          label: "网点赠送厂家积分",
          width: 140,
          align: "center"
        },
        {
          prop: "orgTypeName",
          label: "厂家赠送厂家积分",
          width: null,
          align: "center"
        },
        {
          prop: "dlrCode",
          label: "代金券",
          width: null,
          align: "center"
        },
        {
          prop: "dlrCode",
          label: "折扣",
          width: null,
          align: "center"
        },
        {
          prop: "provinceName",
          label: "发放次数",
          width: null,
          align: "center"
        },
        {
          prop: "dlrCode",
          label: "开始日期",
          width: null,
          align: "center"
        },
        {
          prop: "carBrandCn",
          label: "结束日期",
          width: null,
          align: "center"
        }
      ],
      //表单查询数据（查询条件）
      formField: {
        carBrandCode: "",
        cityId: "",
        dlrShortName: "",
        dlrStatus: "",
        isEnable: "1",
        orgType: "",
        provinceId: ""
      }
    };
  },
  mounted() {
    this.formField.isEnable = "1";
  },
  methods: {}
};
</script>
